package com.zmn.oms.services.impl.nonstandard;

import com.zmn.oms.model.entity.nonstandard.OrderNonstandard;
import com.zmn.oms.persistence.interfaces.nonstandard.OrderNonstandardDao;
import com.zmn.oms.services.interfaces.nonstandard.OrderNonstandardService;
import io.shardingsphere.api.HintManager;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author ：SongWeidong
 * @date ：2020/7/30 19:24
 * @description：非标信息
 */
@Service
public class OrderNonstandardServiceImpl implements OrderNonstandardService {

    @Resource
    OrderNonstandardDao orderNonstandardDao;


    @Override
    public OrderNonstandard findNonstandardByKey(Long nonstandardId) {
        return orderNonstandardDao.findNonstandardByKey(nonstandardId);
    }

    public List<OrderNonstandard> listNonstandardByOrderIdList(List<Long> orderIdList) {
        try (HintManager hintManager = HintManager.getInstance()) {
            hintManager.setMasterRouteOnly();
            return orderNonstandardDao.listNonstandardByOrderIdList(orderIdList);
        }
    }

    @Override
    public List<OrderNonstandard> listNonstandardByOrderId(Long orderId) {
        return orderNonstandardDao.listNonstandardByOrderId(orderId);
    }

    @Override
    public void insertNonstandardList(List<OrderNonstandard> nonstandardList) {
        orderNonstandardDao.insertNonstandardList(nonstandardList);
    }

    @Override
    public void updateBatch(List<OrderNonstandard> nonstandardList) {
        orderNonstandardDao.updateBatch(nonstandardList);
    }

    @Override
    public void deleteByOrderId(Long orderId) {
        orderNonstandardDao.deleteByOrderId(orderId);
    }
}
